package 分类.二叉树;

public class 翻转二叉树 {
    public TreeNode invertTree(TreeNode root) {
        if(root==null) return root;
        reverse(root);
        return root;
    }

    void reverse(TreeNode node){
        if(node==null) return;
        TreeNode left=node.left;
        TreeNode right=node.right;
        node.left=node.right;
        node.right=left;
        reverse(node.left);
        reverse(node.right);
    }
}
